package com.yehongyu.mytools.ui.applet;

import java.applet.Applet;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.TextField;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

public class RadioButtonApplet extends Applet implements ItemListener{

	/**序列ID*/
	private static final long serialVersionUID = 1L;

	TextField t = new TextField("Radio button 2", 30);

	CheckboxGroup g = new CheckboxGroup();
	Checkbox cb1 = new Checkbox("one", g, false), cb2 = new Checkbox("two", g,
			true), cb3 = new Checkbox("three", g, false);

	public void init() {
		t.setEditable(false);
		add(t);
		add(cb1);
		add(cb2);
		add(cb3);
		cb1.addItemListener(this);
		cb2.addItemListener(this);
		cb3.addItemListener(this);
	}

	@Override
	public void itemStateChanged(ItemEvent e) {
		if (e.getSource().equals(cb1)){
			t.setText("Radio button 1");
		}else if (e.getSource().equals(cb2)){
			t.setText("Radio button 2");
		}else if(e.getSource().equals(cb3)){
			t.setText("Radio button 3");
		}else{
			System.out.println("Object is [" + e.getSource() + "],Unknown Action!");
		}
		
	}

}
